import React, {PureComponent} from "react";
import {View, Text, StyleSheet, TouchableOpacity, Image, PixelRatio, Dimensions} from "react-native";
import {color} from "../../widget/color";
const {width} = Dimensions.get('window');
type Props = {
    info: Object,
    subtitle:string,
    btn_color:string,
    font_color:string,
    onPress: Function,
    index:number,
}

class AlteredLessonCell extends PureComponent<Props> {

    render() {
        let {info, subtitle,btn_color,font_color} = this.props

        return <TouchableOpacity onPress={() => this.props.onPress(info)}
                                 style={{flexDirection:'row',paddingTop:15,paddingBottom:15,backgroundColor:'#F8F8F8',marginLeft:12,marginRight:12,alignItems:'center',borderRadius:4,marginTop:12}}>
            <View>
                <Text numberOfLines={1}
                      style={{color:'#333333',fontSize:13,marginRight:10,marginLeft:15,maxWidth:(width - 130)}}>{(this.props.index + 1) + "：" + info.title}</Text>
                <View style={{flexDirection:'row',alignItems:'center',marginTop:10,marginLeft:15}}>
                    <Text
                        style={{color:'#333333',fontSize:13,}}>截止日期：</Text>
                    <Text
                          style={{color:'#999999',fontSize:13,marginLeft:6}}>{info.homework_end_at.substr(0, 16)}</Text>
                </View>
            </View>
            <View style={{flex:1}}/>
            <View
                style={{width:67,height:20,backgroundColor:btn_color,borderRadius:10,justifyContent:'center',alignItems:'center',marginRight:15}}>
                <TouchableOpacity onPress={() => this.props.onsubmit(info)}>
                    <Text style={{fontSize:12,color:font_color,}}>{subtitle}</Text>
                </TouchableOpacity>
            </View>
        </TouchableOpacity>
    }
}


const styles = StyleSheet.create({

    container: {
        flex: 1,
    },
    around: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        paddingRight: 12,
        paddingBottom: 12,
        paddingTop: 12,
    },
    title_left: {
        marginLeft: 15,
        color: 'black',
        fontSize: 12,
    },
    content: {
        color: 'rgba(0, 0, 0, 0.5)',
        fontSize: 13,
    },
    content2: {
        color: 'black',
        fontSize: 13,
        marginLeft: 8
    },
    content_right: {
        color: '#666666',
        fontSize: 13,
    },
    line_data: {
        flexDirection: 'row',
        alignItems: 'center'
    },
    lines: {
        height: 0.5,
        width: width - 24,
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        marginBottom: 12,
        marginRight: 12
    },
    submit_btn: {
        marginLeft: 15,
        borderRadius: 13,
        backgroundColor: '#DB3843',
        height: 25,
        width: 67,
        justifyContent: 'center',
        alignItems: 'center'
    },
    around_bottom: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        paddingRight: 12,
        paddingBottom: 12,
        alignItems: 'center'

    },
    bg: {
        backgroundColor: 'white',
        borderRadius: 5,
        flex: 1,
        shadowColor: '#B5B5B6',
        shadowOffset: {h: 2, w: 2},
        shadowRadius: 1,
        shadowOpacity: 0.4,
        marginTop: 6,
        marginLeft: 12,
        marginRight: 12,
        marginBottom: 6,
        flexDirection: 'row'
    }

})

export default AlteredLessonCell
